package com.LC._55;

class Solution {
    public boolean canJump(int[] nums) {
        if(nums.length==1&&nums[0]==0){
            return true;
        }
        boolean res = true;
        int step;
        for(int i=0;i<nums.length;){
            if(nums[i]==0){
                return false;
            }
            step =nums[i];
            i+=step;
            if(i==nums.length-1){
                return true;
            }
            if(i>=nums.length){
                return false;
            }

        }
        return res;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        int[] nums = new int[]{2,0,0};
        System.out.println(s.canJump(nums));
    }
}